package cn.tedu.mapper;

import cn.tedu.entity.User;
import cn.tedu.vo.UserVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {
    @Select("SELECT id,username,password,age,phone,email FROM t_user WHERE id=#{id}")
    User findUserById(Integer id);
    @Select("SELECT id,username,password,age,phone,email FROM t_user")
     List<User> findAllUser();

    @Insert("INSERT INTO t_user (username,password,age,phone,email)"+
            "VALUES(#{username},#{password},#{age},#{phone},#{email})")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    Integer Insert(User user);

    @Update("UPDATE t_user SET " +
            "username=#{username}," +
            "password=#{password}," +
            "age=#{age}," +
            "phone=#{phone}," +
            "email=#{email} WHERE id=#{id}"
    )
    Integer updateUser(User user);

    @Update("UPDATE t_user SET " +
            "email=#{email} WHERE id=#{id}"
    )
    Integer updateEmail(@Param("email") String email,@Param("id") Integer id);

    @Delete("DELETE FROM t_user WHERE id=#{id}"
    )
    public int deleteUser(int id);

    Integer deleteByIds(Integer... ids);

    Integer updateUserInfo(User user);

    List<User> findUserByParams(
            @Param("username") String username,
            @Param("age") Integer age,
            @Param("phone") String phone
    );

    List<UserVO> findUserDepaerment();
}
